const respCig = require('../config/response')
module.exports = {
  sendHTML(req, resp) {
    let myPath = req.url;
    let newPath = myPath.split('.');
    // console.log('', myPath, newPath)
    if (newPath[1] == "js") newPath = 'javaScript';
    respCig.resp(resp, "src" + myPath, { "content-type": `text/${newPath[1]};charset=utf-8` })
  },
  sendImage(req, resp) {
    let myPath = req.url;
    let newPath = myPath.split('.');
    // console.log('', myPath, newPath)
    respCig.resp(resp, "src" + myPath, { "content-type": `image/${newPath[1]};`,"Cache-Control":"must-revalidate, max-age=60" })  // 设置浏览器缓存。缓存时间为60秒
  },
  sendIco(req, resp) {
    let myPath = req.url;
    let newPath = myPath.split('.');
    // console.log('', myPath, newPath)
    respCig.resp(resp, "src/images" + myPath, {})
  }
}